package com.khshop.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.khshop.pojo.Menu;
import com.khshop.mapper.MenuMapper;
import com.khshop.service.MenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 菜单按钮 服务实现类
 * </p>
 *
 * @author zhaoyang
 * @since 2020-10-08
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {

    @Autowired(required = false)
    private MenuMapper menuMapper;


    @Override
    public IPage findAllMenu(Integer page, Integer limit) {
        Page<Menu> iPage = new Page<Menu>(page,limit);
        return menuMapper.selectPage(iPage,null);

    }

    @Override
    public boolean addMenu(Menu menu) {
        return menuMapper.insert(menu)>0;
    }

    @Override
    public boolean updateMenu(Menu menu) {
        return menuMapper.updateById(menu)>0;
    }

    @Override
    public boolean delMenu(Long id) {
        return menuMapper.deleteById(id)>0;
    }
}
